package cn.liutao.order.api;

import cn.liutao.common.entity.LoginUser;
import cn.liutao.common.enums.OrderEnum;
import cn.liutao.common.utils.ServletUtils;
import cn.liutao.common.utils.ValidUtil;
import cn.liutao.order.entity.param.OrderParam;
import cn.liutao.order.service.OrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.groups.Default;
import java.io.IOException;


/**
 * @author liutao
 * @Description 订单出餐接口
 * @date 2023/11/2 9:28
 * @Version 1.0
 */
@WebServlet("/order/served")
public class OrderServedServlet extends HttpServlet {

    private OrderService orderService;

    @Override
    public void init() throws ServletException {
        orderService = OrderService.getInstance();
    }

    @Override
    /**
     * 出餐操作
     */
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderParam orderParam = ServletUtils.getBodyParam(req, OrderParam.class);
        ValidUtil.validated(orderParam, Default.class);
        orderService.served(orderParam.getOrderNo());
        ServletUtils.ok(resp,"出餐成功");
    }
}
